# -*- coding: utf-8 -*-
"""
Created on Wed Nov 25 18:00:59 2020

@author: NETON
"""

#Hello, welcome to the UMAP script version 1.0#
# Main arguments: pd.read_csv - "add file path"
# You can change n_neighbours, min_dist and metric,
# however, confirm with papers and UMAP online
# digits.Row_Labels.map - also change the name for the name of the rows
# in the raw file
# always use \\ for filepath

import pandas as pd
import umap
import seaborn as sns
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

digits =pd.read_csv("C:\\Users\\neton\\Desktop\\Donor-Global-UMAP 2.0\\Treatment C\\DonorH_TreatC_Global.csv")
print (digits)

digits = digits.dropna()
digits.Row_Labels.value_counts()

# this only plots all the data in 2D plots, so if you have 5 parameters,
#it will generate 25 plots

#x = sns.pairplot(digits, hue='Row_Labels')

#UMAP Starts Here
#avoid changins these parameters, or keep them isolated between experiments/projects
reducer = umap.UMAP(n_neighbors=3,
                    min_dist=0.3,
                    metric='cosine',
                     random_state=40
                     )


FLIM_data = digits[
   [
     'Sum of tau[1][ns]',
     'Sum of tau[2][ns]',
     'Sum of A_rel[1][]',
     'Sum of A_rel[2][]',
     'Tavg',
     'ORR'
 
     ]
    ].values

scaled_FLIM_data = StandardScaler().fit_transform(FLIM_data)
embedding = reducer.fit_transform(scaled_FLIM_data)
embedding.shape

#UMAP ends Here

plt.scatter(
    embedding[:,0],
    embedding[:,1],
    c=[sns.color_palette("tab10")[x] 
       for x in digits.Row_Labels.map({"M1":0, "M2":1})]
)

plt.gca().set_aspect('equal','datalim')
plt.xlabel('UMAP dimension 1')
plt.ylabel('UMAP dimension 2')
#set legend manually here
blue_color= mpatches.Patch(color="blue",hatch="/", label= "M1")
orange_color= mpatches.Patch(color="darkorange", label="M2")
plt.legend(handles=[blue_color,orange_color],loc="best")
#end of legend set up
plt.title('UMAP projection of Treatment B', fontsize=18)


exit()



